//
//  GRRiceOrderModel.m
//  YC_GRice
//
//  Created by luojinrong11 on 2018/9/7.
//  Copyright © 2018年 YeCai. All rights reserved.
//

#import "GRRiceOrderModel.h"
#import "GRGoodDetailPageModel.h"
@implementation GRRiceOrderModel
- (BOOL)modelCustomTransformFromDictionary:(NSDictionary *)dic{
NSArray *discoutArr = dic[@"discountDetail"];
if (Array(discoutArr)) {
    NSMutableArray * countArr = [NSMutableArray array];
    for (NSDictionary *detailDic in discoutArr) {
        GRGoodCountModel * countModel = [[GRGoodCountModel alloc]init];
        countModel.isTitle = YES;
        countModel.title = detailDic[@"title"];
        [countArr addObject:countModel];
        for (NSString * goodName in detailDic[@"items"]) {
            GRGoodCountModel * countModel = [[GRGoodCountModel alloc]init];
            countModel.isTitle = NO;
            countModel.title = goodName;
            [countArr addObject:countModel];
        }
    }
    self.discountDetail = countArr;
    
    
    NSArray * buyNoticeArr = dic[@"buyNotice"];
    if (Array(buyNoticeArr)) {
        NSMutableArray * noticeArr = [NSMutableArray array];
        for (NSDictionary * buyNoticeDic in buyNoticeArr) {
            GRGoodDetailMsgModel *buyNoticeModel = [GRGoodDetailMsgModel yy_modelWithDictionary:buyNoticeDic];
            [noticeArr addObject:buyNoticeModel];
        }
        self.buyNotice = noticeArr;
    }
}
    NSMutableArray * evaluateImageArr = [NSMutableArray array];
    _goodsEvaluateImg = evaluateImageArr;
    return YES;
}

-(CGFloat)statusCellHeigth{
    return 130;
}

-(CGFloat)codeCellHeight{
    if ([self.state isEqualToString:@"refund"]||[self.state isEqualToString:@"expired"]) {
        return 285;
    }else{
         return  313;
    }
  
}

-(CGFloat)orderMsgHeight{
    return 130;
}

-(CGFloat)goodDetailCllHeight{
    if ([self.state isEqualToString:@"pay"]) {
        return 190;
    }else{
        if (self.discountPrice  <=0) {
            return 230;
        }else{
            return 280;
        }
    }
}

-(CGFloat)goodCellHeight{
    return 35;
}

-(CGFloat)getCellHeightWith:(NSString *)cellIdetifier{
// @[@"GRRiceStatusCell",@"GRRiceCodeCell",@"GRRiceOderDetailGoodCell",@"GRGoodCountTableViewCell",@"GRBuyMsgTableViewCell",@"GRRiceOrderMsgCell"];
    if ([cellIdetifier  isEqualToString:@"GRRiceStatusCell"]) {
      return   [self statusCellHeigth];
    }else if ([cellIdetifier isEqualToString:@"GRRiceCodeCell"]){
        return [self codeCellHeight];
    }else if ([cellIdetifier isEqualToString:@"GRRiceOderDetailGoodCell"]){
        return [self goodDetailCllHeight];
    }else if([cellIdetifier isEqualToString:@"GRGoodCountTableViewCell"]){
        return [self goodCellHeight];
        
    }else if ([cellIdetifier isEqualToString:@"GRRiceOrderMsgCell"]){
        return [self orderMsgHeight];
    }else{
        return 68;
    }
}



+ (NSArray *)modelPropertyBlacklist {
    return @[
             @"discountDetail",
             @"buyNotice",
              @"goodsEvaluateImg"
             ];
}

@end
